package com.example.excel.pojo;

import java.util.ArrayList;
import java.util.List;

public class BaseSheet<T> {

    private int sheetIndex;

    private String sheetName;

    private List<BaseRow<T>> rowList;

    private BaseExcel<T> excel;

    public BaseSheet(int sheetIndex, String sheetName, BaseExcel<T> excel) {
        this.sheetIndex = sheetIndex;
        this.sheetName = sheetName;
        this.excel = excel;
    }

    public String getSheetName() {
        return sheetName;
    }

    public int getSheetIndex() {
        return sheetIndex;
    }

    public List<BaseRow<T>> getRowList() {
        return rowList;
    }

    private void addRow(BaseRow<T> row){
        if(rowList==null){
            rowList = new ArrayList<>();
        }
        rowList.add(row);
    }

    public BaseExcel<T> getExcel() {
        return excel;
    }

    public BaseRow<T> createRow(int rowNum){
        BaseRow<T> row = new BaseRow<>(rowNum, this);
        addRow(row);
        return row;
    }

}
